
Version=4.6p1
InstallDir:=usr/local/
InstLibDir:=usr/lib
InstEtcDir:=/usr/local/etc

.PHONY: all clean dist_clean

all:openssh.tgz

# Notice:
# If Make don't find file that copyed, go into dir of source and exec "make install".
openssh.tgz: openssh-$(Version).tar.gz sshd_config
	tar -xzf openssh-$(Version).tar.gz
	mkdir -p $(InstallDir)
	cd openssh-$(Version);./configure --with-md5-passwords \
	--sysconfdir=/usr/local/etc 
	$(MAKE) -C openssh-$(Version)
	$(MAKE) -C openssh-$(Version) install DESTDIR=`pwd`/
	mkdir -p $(InstLibDir);
	cp -rf $(InstEtcDir)/ssh_host_key usr/local/etc
	cp -rf $(InstEtcDir)/ssh_host_dsa_key usr/local/etc
	cp /lib/tls/libresolv-2.3.6.so $(InstLibDir)
	cp /lib/libutil-2.3.6.so $(InstLibDir)
	cp /usr/lib/libz.so.1.2.3 $(InstLibDir)
	cd $(InstLibDir);\
	ln -sf libresolv-2.3.6.so libresolv.so.2;\
	ln -sf libutil-2.3.6.so libutil.so.1;\
	ln -sf libz.so.1.2.3 libz.so.1;
	rm -rf usr/local/share/man/*
	cp sshd_config usr/local/etc/
	mv var/empty usr/ && ln -sf /usr/empty var/empty
	tar -czf openssh.tgz usr var

clean:
	rm -rf *.tgz usr tmp var

dist_clean:clean
	rm -rf *.tar.gz openssh-$(Version) var
	

include ../Makefile.Res
